import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("多列ComboBox")

    ComboBox {
        id: multiColumnCombo
        width: 300
        height: 30
        anchors.centerIn: parent

        delegate: ItemDelegate {
            width: parent.width
            Row {
                spacing: 10
                Text {
                    text: modelData.name
                    width: 100
                    elide: Text.ElideRight
                }
                Text {
                    text: modelData.code
                    width: 50
                    color: "gray"
                }
                Text {
                    text: modelData.region
                    width: 100
                    color: "gray"
                }
            }
        }

        model: [
            { name: "北京", code: "010", region: "华北" },
            { name: "上海", code: "021", region: "华东" },
            { name: "广州", code: "020", region: "华南" }
        ]

        displayText: currentText + " (" + model[currentIndex].code + ")"
    }
}
